<?php
/**
 * Created by PhpStorm.
 * User: xaq
 * Date: 2017/5/11
 * Time: 15:30
 */

namespace app\api\controller\v1;

use app\api\controller\BaseController;
use app\lib\exception\BannerMissException;
use app\api\validate\IDMustBePostiveInt;
use app\api\model\Banner as BannerModel;


class Banner extends BaseController
{
    public function getBanner($id)
    {
        // AOP 面向切面编程
        (new IDMustBePostiveInt()) -> goCheck();
        $banner = BannerModel::getBannerById($id);
        if(!$banner) {
            throw new BannerMissException();   //自定义抛出异常
        }
        return $banner;

    }

}